package com.yykj.user.center.server.controller.patient;

import com.yykj.common.vo.ResultVO;
import com.yykj.user.center.server.form.AddPatientCardInfoForm;
import com.yykj.user.center.server.form.RemoveBindingForm;
import com.yykj.user.center.server.form.UpdatePatientCardInfoForm;
import com.yykj.user.center.server.service.patient.PatientCardInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author chenl
 * @version 1.0
 * @date 2021/11/1 14:42
 */
@Api(tags = "就诊卡相关接口")
@RestController
@RequestMapping("/api/patientCard")
@SuppressWarnings("unchecked")
@Slf4j
public class PatientCardInfoController {
    @Autowired
    private PatientCardInfoService patientCardInfoService;

    @GetMapping("/showPatientCardList")
    @ApiOperation("查看该账户绑定的就诊卡信息")
    public ResultVO showPatientCardList(){
        return ResultVO.success(patientCardInfoService.showPatientCardList());
    }

    @PostMapping("/addPatientCard")
    @ApiOperation("添加就诊卡人并绑定")
    public ResultVO addPatientCard(@Valid @RequestBody AddPatientCardInfoForm addPatientCardInfoForm){
        return ResultVO.success(patientCardInfoService.addPatientCard(addPatientCardInfoForm));
    }

    @PostMapping("/removeBinding")
    @ApiOperation("解除绑定")
    public ResultVO removeBinding( @Valid  @RequestBody RemoveBindingForm removeBindingForm){
        return ResultVO.success(patientCardInfoService.removeBinding(removeBindingForm));
    }

    @PostMapping("/updatePatientCard")
    @ApiOperation("添加就诊卡人并绑定")
    public ResultVO updatePatientCard(@Valid @RequestBody UpdatePatientCardInfoForm updatePatientCardInfoForm){
        return ResultVO.success(patientCardInfoService.updatePatientCard(updatePatientCardInfoForm));
    }

    @GetMapping("/info")
    @ApiOperation("详情")
    public ResultVO info(@RequestParam(value = "id",required = true) String id){
        return ResultVO.success(patientCardInfoService.info(id));
    }
}
